package com.itheima.mapper;

import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 新增套餐
     *
     * @param setmeal
     * @return
     */
    Integer insert(Setmeal setmeal);

    /**
     * 删除套餐
     *
     * @param id
     */
    @Delete("delete from setmeal where id = #{id}")
    void deleteById(Integer id);

    /**
     * 根据套餐名称查询套餐
     *
     * @param name
     * @return
     */
    @Select("select * from setmeal where name = #{name}")
    List<Setmeal> selectByName(String name);

    /**
     * 根据套餐id查询套餐
     *
     * @param id
     * @return
     */
    @Select("select * from setmeal where id = #{id}")
    Setmeal selectById(Integer id);

    /**
     * 修改套餐
     *
     * @param setmeal
     */
    @Update("update setmeal " +
            "set name = #{name}, code = #{code}, help_code = #{helpCode}, sex = #{sex}, age = #{age}, price = #{price}, remark = #{remark}, attention = #{attention}, img = #{img} " +
            "where id = #{id}")
    void update(Setmeal setmeal);

    /**
     * 根据条件查询套餐
     *
     * @param queryString
     * @return
     */
    List<Setmeal> selectByQueryString(String queryString);

    /**
     * 根据套餐id查询关联的预约信息关联数量
     * @param id
     * @return
     */
    @Select("select count(1) from `order` where setmeal_id = #{id}")
    Integer hasNumInRelatedOrder(Integer id);

    /**
     * 根据套餐id查询套餐详情
     * @param id
     * @return
     */
    Setmeal selectDetailById(Integer id);
}
